﻿#pragma once
#include<iostream>
#include<list>
#include<deque>
using namespace std;
namespace QL
{
	//queue可用的容器有：list,deque
	template<class T, class Container = list<T>>
	class Queue
	{
	public:
		void push(const T& x)
		{
			_con.push_back(x);
		}
		T& back()
		{
			return _con.back();
		}
		const T& back() const
		{
			return _con.back();
		}
		T& front()
		{
			return _con.front();
		}
		const T& front() const 
		{
			return _con.front();
		}
		void pop()
		{
			_con.pop_front();
		}
		bool empty() const
		{
			return _con.empty();
		}
		size_t size() const
		{
			return _con.size();
		}
	private:
		Container _con;
	};

	void test_queue()
	{
		Queue<int> q;
		q.push(1);
		q.push(2);
		q.push(3);
		q.push(4);
		q.push(5);

		while (!q.empty())
		{
			cout << q.front() << " ";
			q.pop();
		}
		cout << endl;

		Queue<int, deque<int>> dq;
		dq.push(1);
		dq.push(2);
		dq.push(3);
		dq.push(4);
		dq.push(5);

		while (!dq.empty())
		{
			cout << dq.front() << " ";
			dq.pop();
		}
		cout << endl;

	}
}

